
package javatelephone;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;

public class FrameTelephone extends javax.swing.JFrame implements InterfaceUser{
     private boolean isActivate;
     private boolean isMessage;
     private boolean viewMenu;
     private boolean isSend;
     private boolean isVolver;
     private String numbers;
     private int cont;
     public FrameTelephone() {
        initComponents();
        this.isActivate = false;
        this.isMessage = false;
        this.viewMenu = false;
        this.isSend = false;
        this.isVolver = false;
        this.numbers = "";
        this.cont = 0;
        this.setResizable(false);
        this.jButtonVolver.setEnabled(false);
        this.jScrollMailboxMenu.setSize(jScrollPantallaTelephone.getSize());
        this.jListMailboxMenu.setSize(jTextPantallaTelephone.getSize());
        this.jScrollMailboxMenu.setVisible(true);
        this.jListMailboxMenu.setVisible(false);
    }

    public void mostrarMailboxMenu() {
        jScrollPantallaTelephone.setVisible(false);
        jTextPantallaTelephone.setVisible(false);
        jScrollMessageMenu.setVisible(false);
        jListMessageMenu.setVisible(false);
        jScrollMailboxMenu.setVisible(true);
        jListMailboxMenu.setVisible(true);
    }

    public void mostrarMessageMenu() {
        jScrollPantallaTelephone.setVisible(false);
        jTextPantallaTelephone.setVisible(false);
        jListMailboxMenu.setVisible(false);
        jScrollMailboxMenu.setVisible(false);
        jScrollMessageMenu.setVisible(true);
        jListMessageMenu.setVisible(true);
    }

    public void mostrarPantalla() {
        this.jScrollMailboxMenu.setVisible(false);
        this.jListMailboxMenu.setVisible(false);
        this.jScrollMessageMenu.setVisible(false);
        this.jListMessageMenu.setVisible(false);
        this.jScrollPantallaTelephone.setVisible(true);
        this.jTextPantallaTelephone.setVisible(true);
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jTextSpeaker = new javax.swing.JTextField();
        jButtonVolver = new javax.swing.JButton();
        jButton0 = new javax.swing.JButton();
        jTextMicrophone = new javax.swing.JTextField();
        jButtonNumeral = new javax.swing.JButton();
        jButtonok = new javax.swing.JButton();
        jButtonMenu = new javax.swing.JButton();
        jScrollPantallaTelephone = new javax.swing.JScrollPane();
        jTextPantallaTelephone = new javax.swing.JTextArea();
        jScrollMailboxMenu = new javax.swing.JScrollPane();
        jListMailboxMenu = new javax.swing.JList();
        jScrollMessageMenu = new javax.swing.JScrollPane();
        jListMessageMenu = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Telephone\n");
        setName("Form"); // NOI18N

        jButton1.setText("1");
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("2");
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("3");
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton4.setText("4");
        jButton4.setName("jButton4"); // NOI18N
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("5");
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("6");
        jButton6.setName("jButton6"); // NOI18N
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jButton7.setText("7");
        jButton7.setName("jButton7"); // NOI18N
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jButton8.setText("8");
        jButton8.setName("jButton8"); // NOI18N
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jButton9.setText("9");
        jButton9.setName("jButton9"); // NOI18N
        jButton9.setPreferredSize(new java.awt.Dimension(40, 40));
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jTextSpeaker.setName("jTextSpeaker"); // NOI18N

        jButtonVolver.setText("Salir");
        jButtonVolver.setName("jButtonVolver"); // NOI18N
        jButtonVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonVolverActionPerformed(evt);
            }
        });

        jButton0.setText("0");
        jButton0.setName("jButton0"); // NOI18N
        jButton0.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton0ActionPerformed(evt);
            }
        });

        jTextMicrophone.setName("jTextMicrophone"); // NOI18N
        jTextMicrophone.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextMicrophoneKeyPressed(evt);
            }
        });

        jButtonNumeral.setText("#");
        jButtonNumeral.setName("jButtonNumeral"); // NOI18N
        jButtonNumeral.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNumeralActionPerformed(evt);
            }
        });

        jButtonok.setText("OK");
        jButtonok.setName("jButtonok"); // NOI18N
        jButtonok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonokActionPerformed(evt);
            }
        });

        jButtonMenu.setText("Menu");
        jButtonMenu.setName("jButtonMenu"); // NOI18N
        jButtonMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMenuActionPerformed(evt);
            }
        });

        jScrollPantallaTelephone.setName("jScrollPantallaTelephone"); // NOI18N

        jTextPantallaTelephone.setColumns(20);
        jTextPantallaTelephone.setRows(5);
        jTextPantallaTelephone.setName("jTextPantallaTelephone"); // NOI18N
        jScrollPantallaTelephone.setViewportView(jTextPantallaTelephone);

        jScrollMailboxMenu.setName("jScrollMailboxMenu"); // NOI18N
        jScrollMailboxMenu.setPreferredSize(new java.awt.Dimension(166, 96));

        jListMailboxMenu.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Listen to your messages", "Change your passcode", "Change your greeting" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jListMailboxMenu.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jListMailboxMenu.setName("jListMailboxMenu"); // NOI18N
        jListMailboxMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jListMailboxMenuMouseClicked(evt);
            }
        });
        jScrollMailboxMenu.setViewportView(jListMailboxMenu);

        jScrollMessageMenu.setName("jScrollMessageMenu"); // NOI18N

        jListMessageMenu.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Listen to the current message", "Save the current message", "Delete the current message", "Return to the main menu" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jListMessageMenu.setName("jListMessageMenu"); // NOI18N
        jListMessageMenu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jListMessageMenuMouseClicked(evt);
            }
        });
        jScrollMessageMenu.setViewportView(jListMessageMenu);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextMicrophone, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .addComponent(jScrollPantallaTelephone, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .addComponent(jTextSpeaker, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonok, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonNumeral, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                            .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)
                            .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                            .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                            .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
                            .addComponent(jButton0, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                            .addComponent(jButtonVolver, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                            .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE)
                            .addComponent(jButton6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 78, Short.MAX_VALUE))))
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollMailboxMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .addContainerGap()))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jScrollMessageMenu, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                    .addContainerGap()))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextSpeaker, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPantallaTelephone, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonok, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)
                        .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE))
                    .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonNumeral, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonVolver, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton0, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextMicrophone, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(63, 63, 63)
                    .addComponent(jScrollMailboxMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(354, Short.MAX_VALUE)))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(63, 63, 63)
                    .addComponent(jScrollMessageMenu, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(355, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonMenuActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButtonMenuActionPerformed
        viewMenu = true;
        isActivate = true;
        jButtonVolver.setEnabled(true);
        numbers = "";
        mostrarMailboxMenu();
    }//GEN-LAST:event_jButtonMenuActionPerformed

    private void jButtonokActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButtonokActionPerformed
       this.isActivate = true;
       this.numbers = "";
    }//GEN-LAST:event_jButtonokActionPerformed

    private void jButton1ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       jTextPantallaTelephone.setText("1");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
       jTextPantallaTelephone.setText("2");
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
       jTextPantallaTelephone.setText("3");
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("4");
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("5");
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton6ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("6");
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton7ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("7");
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("8");
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton9ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("9");
    }//GEN-LAST:event_jButton9ActionPerformed

    private void jButton0ActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButton0ActionPerformed
        // TODO add your handling code here:
        jTextPantallaTelephone.setText("0");
    }//GEN-LAST:event_jButton0ActionPerformed

    private void jButtonVolverActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButtonVolverActionPerformed
        jTextPantallaTelephone.setText(null);
        jTextSpeaker.setText(null);
        isVolver = true;
        jScrollPantallaTelephone.setVisible(true);
        jTextPantallaTelephone.setVisible(true);
    }//GEN-LAST:event_jButtonVolverActionPerformed

    private void jButtonNumeralActionPerformed(ActionEvent evt) {//GEN-FIRST:event_jButtonNumeralActionPerformed

        jTextPantallaTelephone.setText("#");
    }//GEN-LAST:event_jButtonNumeralActionPerformed

    private void jTextMicrophoneKeyPressed(KeyEvent evt) {//GEN-FIRST:event_jTextMicrophoneKeyPressed
        if (evt.getKeyCode() == 10) {
            this.isMessage=true;
            this.isActivate = true;
            this.numbers = "";
        }
    }//GEN-LAST:event_jTextMicrophoneKeyPressed

    private void jListMailboxMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListMailboxMenuMouseClicked
        switch(jListMailboxMenu.getSelectedIndex())
        {
            case 0:
                jTextPantallaTelephone.setText("1");
                isActivate = true;
                numbers = "";
                break;
            case 1:
                jTextPantallaTelephone.setText("2");
                this.isActivate = true;
                this.numbers = "";
                this.mostrarPantalla();
                break;
            case 2:
                jTextPantallaTelephone.setText("3");
                isActivate = true;
                numbers = "";
                mostrarPantalla();
                break;
        }
    }//GEN-LAST:event_jListMailboxMenuMouseClicked

    private void jListMessageMenuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListMessageMenuMouseClicked
       switch(jListMessageMenu.getSelectedIndex())
        {
            case 0:
                jTextPantallaTelephone.setText("1");
                isActivate = true;
                numbers = "";
                break;
            case 1:
                jTextPantallaTelephone.setText("2");
                isActivate = true;
                numbers = "";
                break;
            case 2:
                jTextPantallaTelephone.setText("3");
                isActivate = true;
                numbers = "";
                break;
            case 3:
                jTextPantallaTelephone.setText("4");
                isActivate = true;
                numbers = "";
                break;
        }
    }//GEN-LAST:event_jListMessageMenuMouseClicked
    public void setIsActivate(boolean isActivate) {
        this.isActivate = isActivate;
    }

    public void setIsMessage(boolean isMessage) {
        this.isMessage = isMessage;
    }

    public void setViewMenu(boolean viewMenu) {
        this.viewMenu = viewMenu;
    }

    public void setIsSend(boolean isSend) {
        this.isSend = isSend;
    }

    public void setIsVolver(boolean isVolver) {
        this.isVolver = isVolver;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton0;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JButton jButtonMenu;
    private javax.swing.JButton jButtonNumeral;
    private javax.swing.JButton jButtonVolver;
    private javax.swing.JButton jButtonok;
    private javax.swing.JList jListMailboxMenu;
    private javax.swing.JList jListMessageMenu;
    private javax.swing.JScrollPane jScrollMailboxMenu;
    private javax.swing.JScrollPane jScrollMessageMenu;
    private javax.swing.JScrollPane jScrollPantallaTelephone;
    private javax.swing.JTextField jTextMicrophone;
    private javax.swing.JTextArea jTextPantallaTelephone;
    private javax.swing.JTextField jTextSpeaker;
    // End of variables declaration//GEN-END:variables

    @Override
    public String DiscardTelephone() {
        
        if(isActivate)
        {
            if(isMessage)
            {
               numbers = jTextMicrophone.getText();
               jTextMicrophone.setText(null);
               isActivate = false;
               this.isSend=true;
               return numbers;
            }
            else
            {
                numbers = jTextPantallaTelephone.getText();
                jTextPantallaTelephone.setText(null);
                isActivate = false;
                return numbers;
            }
        }
        else
        { 
             if(isSend)
             {
                 isSend = false;
                 isMessage = false;
                 return "H";
             }
             else if(viewMenu && cont <= 3)
                  {
                     switch(cont)
                     {
                         case 0: 
                              cont++;
                              return "1";
                         case 1:
                              cont++;
                              return "#";
                         case 2:
                              cont++;
                              return "1";
                         case 3:
                             viewMenu =false;
                             cont = 0; 
                             return "#";
                     }
             }
             if(isVolver)
             {
                 this.isVolver = false;
                 this.isActivate = false;
                 this.viewMenu = false;
                 return "H";
             }
             return "";
        }
    }
    @Override
    public void ViewMessageTelephone(String Message) {
        if (Message.equals("Enter 1 to listen to your messages\n"
         + "Enter 2 to change your passcode\n"
         + "Enter 3 to change your greeting")) 
        {
             jTextPantallaTelephone.setText("");
             mostrarMailboxMenu();
             jTextSpeaker.setText(null);
        }
       else if (Message.equals( "Enter 1 to listen to the current message\n"
         + "Enter 2 to save the current message\n"
         + "Enter 3 to delete the current message\n"
         + "Enter 4 to return to the main menu")) {
            this.jTextPantallaTelephone.setText("");
            this.mostrarMessageMenu();
            this.jTextSpeaker.setText(null);
        }
         else if(Message.length()>149 && Message.substring(Message.length() -149,Message.length()).equals("Enter 1 to listen to the current message\n"
         + "Enter 2 to save the current message\n"
         + "Enter 3 to delete the current message\n"
         + "Enter 4 to return to the main menu"))
         {
            jTextPantallaTelephone.setText("");
            jTextSpeaker.setText("Current Message:"+Message.substring(0, Message.length()-149));
            mostrarMessageMenu();
         }
         else
         {
            jTextPantallaTelephone.setText(null);
            jTextSpeaker.setText(Message);     
         }
    }
}
